/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package pl.mwas.proteana.file.parsers;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import pl.mwas.proteana.file.readers.ProteanaFileReader;

/**
 *
 * @author loskov
 */
public abstract class FileParser {
    
    protected ArrayList parsedOutput = null;
    
    public FileParser(String path) throws IOException {
        parsedOutput = new ArrayList<>();
        parseFile(new File(path));
    }

    public FileParser(File file) throws IOException {
        parsedOutput = new ArrayList<>();
        parseFile(file);
    }

    protected void parseFile(File file) throws IOException {
        ProteanaFileReader reader = new ProteanaFileReader(file);
        ArrayList<String> fileOutput = reader.getOutput();
        for (String line : fileOutput) {
            parseLine(line);
        }
    }

    public ArrayList getParsedOutput() {
        return parsedOutput;
    }

    protected abstract void parseLine(String line);
    
}
